﻿using Microsoft.AspNetCore.Mvc;
using Single.Core.Service;
using Single.Json;
using Single.Sys.Entity;
using Single.WebApp.Components;

namespace Single.WebApp.Areas.Sys.Controllers
{
    [Area("Sys")]
    public class ConfigController : WorkController
    {
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult PwdStrategy()
        {
            return View();
        }

        public string GetData(string prefix)
        {
            var list = ServiceSysProps.SysConfig.GetByPrefix(prefix);

            return ServiceResult.SerializeData(list);
        }

        public string SaveData(string data)
        {
            var list = JsonHelper.Deserialize<List<SysConfig>>(data);

            return ServiceSysProps.SysConfig.SetContent(list).Serialize();
        }
    }
}
